<template>
  <div class="date">
    <span>No.</span>
    <span class="date_date">{{ infoText.indexText }}</span>
    <span class="date_vertical"></span>
    <div class="date_month_year">
      <span>{{ infoText.month }}</span>
      <span>{{ infoText.year }}</span>
    </div>
  </div>
</template>

<script>
import { MONTH_ENUM } from '../../enum/config'
export default {
  props: ["artInfo"],
  computed: {
    infoText() {
      const { index, pubdate } = this.artInfo;
      const indexText = index < 10 ? index.toString().padStart(2, 0) : index;
      const month = new Date(pubdate).getMonth();
      const year = new Date(pubdate).getFullYear();
      return {
        indexText,
        month: MONTH_ENUM[month],
        year
      };
    }
  }
};
</script>

<style scoped>
.date {
  /* 使得文字底部对齐 */
  display: table-cell;
  vertical-align: baseline;
}
.date_date {
  font-size: 48rpx;
  font-weight: bold;
}
.date_vertical {
  height: 50rpx;
  border-left: 1px solid;
  margin: 0 10rpx;
  position: relative;
  bottom: 6rpx;
}
.date_month_year {
  display: inline-flex;
  flex-direction: column;
  font-size: 18rpx;
  position: relative;
  bottom: 22rpx;
}
</style>